/*
 * @Author: 阿芙
 * @Date: 2021-06-14 14:10:28
 * @LastEditTime: 2021-06-15 17:29:06
 * @LastEditors: Please set LastEditors
 * @Description: 处理SQL
 * @FilePath: /RuoLing-SQL/lib/MYSQLDB.js
 */

//获取MYSQL驱动器
const DriversMYSQL = require("./Drivers/DriversMYSQL.js");


/**
 * @description: MYSQLDB构造，用于处理SQL
 * @param {*} config
 * @return {*}
 */
function MYSQLDB(config){
    "use strict";
    this.config = config;
    this.sqldb = null;
    this.Init();
};

 
/**
 * @description: 初始化注入到MYSQL驱动器
 * @param {*}
 * @return {*}
 */
MYSQLDB.prototype.Init = function(){
    "use strict";
    
    let _this = this;
    _this.sqldb = new DriversMYSQL(_this.config);
};


/**
 * @description: 重写queryConnection
 * @param {*}
 * @return {*}
 */
MYSQLDB.prototype.queryConnection = function(){
    "use strict";
    let _this = this;
    return _this.sqldb.queryConnection();
};


/**
 * @description: 重写query
 * @param {*} sql
 * @return {*}
 */
MYSQLDB.prototype.query = function(sql){
    "use strict";
    let _this = this;
    return _this.sqldb.query(sql);
};


MYSQLDB.prototype.close = function () {
    "use strict";
    let _this = this;
    return _this.sqldb.close();
}


module.exports = MYSQLDB;

// let config = {
//     host:"192.168.50.128",
//     user:"root",
//     password:"lvdi123",
//     database:"ruoling_test",
//     connectionLimit : 2,
// }


